Skip to content

Conversation

@Akuukis
Copy link
Contributor

@Akuukis Akuukis commented Aug 11, 2025

💭 Notes

Refactor organization member and invites endpoints to use generated react-query helpers fully with invalidations and optimistic updates.

Use setMutationDefaults as a means to centralize invalidations and optimistic update logic.

👀 Preview steps

  1. have local env with a project
  2. in django admin panel create and enable organization for the super user
  3. in django admin panel create another user
  4. login as superuser, go to http://kf.kobo.local/#/account/organization/members
  5. invite the user
  6. 🟢 notice that invite is in the list
  7. in devtools, set throttling to "GPRS"
  8. edit the invite's role
  9. 🟢 [on pr] notice that invite in the list updates immediately
  10. 🟢 [on pr] notice that api request is sent and succeeds but doesn't re-render the page
    • that's react-query's auto-reconciliation structural sharing working to avoid unnecessary re-renders
  11. in devtools, set throttling to "offline"
  12. edit the invite's role again
  13. 🟢 [on pr] notice that role in the list updates immediately..
    • that's optimistic updates working
  14. 🟢 [on pr] ..but the API request fails..
  15. 🟢 [on pr] ..and the role reverts to previous value
    • that's rolling back optimistic updates working

@Akuukis Akuukis self-assigned this Aug 13, 2025
@Akuukis Akuukis force-pushed the kalvis/api-orval branch 2 times, most recently from 708a733 to 563a626 Compare August 13, 2025 16:39
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch 2 times, most recently from dba2f08 to 3eade12 Compare August 18, 2025 12:03
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from 3eade12 to fc8085c Compare August 18, 2025 12:57
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from fc8085c to cb8f9de Compare August 19, 2025 09:44
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from cb8f9de to bfbd9e4 Compare August 19, 2025 10:19
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from b411641 to 2fa3321 Compare August 25, 2025 12:09
@Akuukis Akuukis force-pushed the kalvis/api-orval branch 4 times, most recently from 60b1e32 to e6aee5a Compare August 25, 2025 14:50
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch 5 times, most recently from c8aaa26 to 6964d89 Compare August 25, 2025 17:34
@Akuukis Akuukis changed the title refactor(invites): use generated react-query DEV-871 refactor(invites): use generated react-query DEV-871 DEV-947 Aug 25, 2025
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from 6964d89 to 56a365a Compare August 26, 2025 09:00
Akuukis added a commit that referenced this pull request Aug 28, 2025
…93 (#6083)

### 💭 Notes

Generate react-query helpers from API with Orval. By it's own does
nothing. See these few refactors, the rest is for now unused generated
files:
- `jsapp/js/api.ts`
- `package.json`
- `package-lock.json`

Configuration is split across these files:
- `orval.config.js`
- `jsapp/js/api/orval.mutator.ts`
- `jsapp/js/api/orval.operationName.ts`
- `scripts/generate_api.sh`
- `.github/workflows/openapi.yml`

See other refactor PRs that use these helpers to call API:
- #6090

### 👀 Preview steps

1. run kobo-install locally
2. `./run.py -cf run --rm kpi ./scripts/generate_api.sh` to re-generate
helpers
3. notice that helpers are regenerated
4. click around so that some APIs are called the old way
5. notice that it still works and the refactors didn't break anything
Base automatically changed from kalvis/api-orval to main August 28, 2025 10:46
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from 56a365a to 7bca51f Compare September 4, 2025 10:11
@Akuukis Akuukis marked this pull request as ready for review October 27, 2025 13:47
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from 7441a31 to 9adbd62 Compare October 27, 2025 14:05
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from 18f0058 to b9c7201 Compare October 27, 2025 16:08
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from 09966a3 to 6536e86 Compare October 29, 2025 10:46
@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from 6536e86 to 9204577 Compare October 29, 2025 10:48
Copy link
Member

@magicznyleszek magicznyleszek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found one problem in the UI:

  1. As org owner go to #/account/organization/members
  2. Use "Invite members" button and in modal invite a member (e.g. "josh" as "Admin")
  3. In the list of members, for "josh" use "…" button and "Remove invitation"
  4. 🟢 Notice the "Invitation removed" notification
  5. 🔴 Notice that "josh" still appears in the list
  6. Switch to different browser tab
  7. Switch back
  8. 🟢 Notice that reactQuery triggers refetch and "josh" disappears from the list

@Akuukis Akuukis force-pushed the kalvis/api-orval-invite branch from d18ca4f to 3f62c19 Compare October 29, 2025 13:05
Copy link
Member

@magicznyleszek magicznyleszek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it works :) Found one typo

@Akuukis Akuukis merged commit 3498d6b into main Oct 30, 2025
11 checks passed
@Akuukis Akuukis deleted the kalvis/api-orval-invite branch October 30, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants